<?php

/*------------------------------------------------
*
*   Explay Engine Content Management System.
*   Copyright © 2008 Golovdinov Alexander.
*
*-------------------------------------------------
*
*   Official site: wwww.alex-home.spb.ru/explay.html
*   Contact e-mail: golovdinov@gmail.com
*
*   GNU General Public License original source:
*   http://www.gnu.org/licenses/gpl-3.0.html
*
------------------------------------------------*/

if (!defined ('EXPLAY')) exit;

include $_SERVER['DOCUMENT_ROOT'].'/modules/articles/interfaces.php';
include $_SERVER['DOCUMENT_ROOT'].'/modules/articles/controller.class.php';

	
$oArticles = articlesController::getInstance();

$oArticles->load_class ($_SERVER['DOCUMENT_ROOT'].'/modules/articles/model.class.php', 'articlesModel');

include $_SERVER['DOCUMENT_ROOT'].'/modules/articles/mysql.class.php';
include $_SERVER['DOCUMENT_ROOT'].'/modules/articles/view.class.php';

// Вывод полной статьи
if (isset($_GET['id']) || isset($_GET['url'])) {
	
	if (!empty ($_GET['id'])) {
		$oArticles->add_filter ('art_id', intval ($_GET['id']));	
	}
	if (!isset($_GET['id']) && isset($_GET['url']) && preg_match("#^[a-z0-9_-]+$#", $_GET['url'])) {
		$oArticles->add_filter ('art_url_name', htmlspecialchars ($_GET['url']));
	}

	$oArticles->past_article ();
		
}
		
// Вывод облака статей
elseif (isset ($_GET['cat']) && $_GET['cat'] == 'tags') {
	
	past_navblock (array (
					array ('Написать статью', '/my_articles/add/', 'cat', 'add'),
					array ('Поиск по тегам', '/articles/tags/', 'cat', 'tags'),
					array ('Комментарии', '/art_comments/', 'name', 'art_comments'),
					array ('TOP блогов', '/top/', 'name', 'top'),
				)
	);
	
	$oArticles->tags_cloud ();

// Вывод списка статей
} else {
	
	if (!isset ($_GET['user'])) {
		past_navblock (array (
					array ('Написать статью', '/my_articles/add/', 'cat', 'add'),
					array ('Поиск по тегам', '/articles/tags/', 'cat', 'tags'),
					array ('Комментарии', '/art_comments/', 'name', 'art_comments'),
					array ('TOP блогов', '/top/', 'name', 'top'),
				)
		);
	}
	
	$oArticles->load_settings ();
	$oArticles->init_page ();
	$oArticles->load_default_filters ();
	$oArticles->past_articles_list ();
}

if ($oArticles->author_properties !== false) {
	
	past_navblock (array (
				array ('Профиль '.$oArticles->author_properties['user_name'], '/users/'.$oArticles->author_properties['user_login'], '0', '0'),
				array ('Блог '.$oArticles->author_properties['user_name'], '/users/'.$oArticles->author_properties['user_login'].'/blog', 'user', $oArticles->author_properties['user_login']),
			)
	);
	
}

$oArticles->show_result ();

